package com.vce.web.util.jackson;

import java.util.Date;
import org.codehaus.jackson.Version;
import org.codehaus.jackson.annotate.JsonAutoDetect;
import org.codehaus.jackson.map.ObjectMapper;
import org.codehaus.jackson.map.module.SimpleModule;
import org.hibernate.SessionFactory;

/**
 * Created by IntelliJ IDEA.
 * User: lruiz
 * Date: 5/25/11
 * Time: 7:04 PM
 * To change this template use File | Settings | File Templates.
 */
public class GetObjectMapper extends ObjectMapper {
    public GetObjectMapper(SessionFactory sessionFactory) {
        super();
        setVisibilityChecker(getVisibilityChecker().withFieldVisibility(JsonAutoDetect.Visibility.ANY));
        SimpleModule simpleModule = new SimpleModule("GetSimpleModule", new Version(1,0,0, null));
        simpleModule.addDeserializer(String.class, new StringTrimmerDeserializer());
        
        simpleModule.addDeserializer(Date.class, new DateDeserializer());
        simpleModule.addSerializer(Date.class, new DateSerializer());
        
        registerModule(simpleModule);
        registerModule(new GetModule(sessionFactory));

        //enableDefaultTyping(DefaultTyping.OBJECT_AND_NON_CONCRETE, JsonTypeInfo.As.PROPERTY);
    }

    public GetObjectMapper() {
        this(null);
    }
}
